<template>
<div>
    用户名:<input type="text" v-model="username">
    密码:<input type="password" v-model="password">
    <button @click="login()">登录</button>
    {{next_path}}
</div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            username:"",
            password:"",
            next_path:this.$route.query.next_path
        }
    },methods: {
        login(){
            var data={
                "username":this.username,
                "password":this.password
            }
            axios({
                url:"http://127.0.0.1:8000/tushulogin",
                method:"post",
                data:data
            }).then(resp=>{
                var uid=resp.data.uid
                alert(resp.data.msg)
                sessionStorage.setItem("uid",uid)
                if(this.next_path!=null){
                    this.$router.push({"path":this.next_path})
                }
            })
        }
    },
}
</script>

<style>

</style>